const { success } = require("./output")

const locale = 'zh-Hans-CN'
const currentTime = Date.now()
const dateFormatter = { hour12: false }

// 获取日期格式化的字符串
const dateFilter = date => date.toLocaleString(locale, dateFormatter)

// 获取毫秒时间格式化的字符串
const getDateString = milliseconds => {
  return new Date(milliseconds).toLocaleString(locale, dateFormatter)
}

// 根据时长获取返校时刻 离校时刻默认为Date.now()
const getTimeByDuration = duration => {
  success('已配置默认离校时长，将根据此时长提交')
  const leaveTime = getDateString(currentTime)
  const returnTime = getDateString(currentTime + (+duration))
  return { leaveTime, returnTime }
}

module.exports = { locale, dateFilter, getTimeByDuration } 